package com.ruoyi.swla2.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.swla2.domain.DingWeiDa;
import com.ruoyi.swla2.service.IDingWeiDaService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 定位档案Controller
 *
 * @author gdqt
 * @date 2023-12-08
 */
@RestController
@RequestMapping("/swla2/dingWeiDa")
public class DingWeiDaController extends BaseController {
    @Autowired
    private IDingWeiDaService dingWeiDaService;

    /**
     * 查询定位档案列表
     */
    @PreAuthorize("@ss.hasPermi('device:terminalsInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(DingWeiDa dingWeiDa) {
        List<DingWeiDa> list = dingWeiDaService.selectDingWeiDaList(dingWeiDa);
        return getDataTable(list);
    }

    /**
     * 导出定位档案列表
     */
    @PreAuthorize("@ss.hasPermi('device:terminalsInfo:export')")
    @Log(title = "定位档案", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DingWeiDa dingWeiDa) {
        List<DingWeiDa> list = dingWeiDaService.selectDingWeiDaList(dingWeiDa);
        ExcelUtil<DingWeiDa> util = new ExcelUtil<DingWeiDa>(DingWeiDa.class);
        util.exportExcel(response, list, "定位档案数据");
    }

    /**
     * 获取定位档案详细信息
     */
    @PreAuthorize("@ss.hasPermi('device:terminalsInfo:query')")
    @GetMapping(value = "/{userId}")
    public AjaxResult getInfo(@PathVariable("userId") String userId) {
        return success(dingWeiDaService.selectDingWeiDaByUserId(userId));
    }

    /**
     * 新增定位档案
     */
    @PreAuthorize("@ss.hasPermi('device:terminalsInfo:add')")
    @Log(title = "定位档案", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DingWeiDa dingWeiDa) {
        return toAjax(dingWeiDaService.insertDingWeiDa(dingWeiDa));
    }

    /**
     * 修改定位档案
     */
    @PreAuthorize("@ss.hasPermi('device:terminalsInfo:edit')")
    @Log(title = "定位档案", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DingWeiDa dingWeiDa) {
        return toAjax(dingWeiDaService.updateDingWeiDa(dingWeiDa));
    }

    /**
     * 删除定位档案
     */
    @PreAuthorize("@ss.hasPermi('device:terminalsInfo:remove')")
    @Log(title = "定位档案", businessType = BusinessType.DELETE)
    @DeleteMapping("/{userIds}")
    public AjaxResult remove(@PathVariable String[] userIds) {
        return toAjax(dingWeiDaService.deleteDingWeiDaByUserIds(userIds));
    }
}
